﻿<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <title>创建群</title>
    <link rel="stylesheet" href="/layui/css/layui.css">
    <link href="~/layui/css/pc/layim/layim.css" rel="stylesheet" />
    <link href="~/layui/css/pc/layer/layer.css" rel="stylesheet" />
    <link href="~/css/search.css" rel="stylesheet" />
    <script src="~/layui/layui.js"></script>
    <script>
        layui.use(['jquery', 'laytpl', 'layer'], function (j, l, ly) {
            var $ = j;
            var laytpl = l;
            var layer = ly;

            var userid = localStorage.getItem('currentUserId');
            $(function () {
                $(document).on('click', '#btnCreateGroup', function () {
                    var groupName = $('#txtGroupName').val()||'新建群';
                    var groupDesc = $('#txtGroupDesc').val();
                    console.log(window.parent.layerIndex);
                    $.post('/layimapi/create', { n: groupName, d: groupDesc, uid: userid }, function (result) {
                        if (result.code == 0) {
                            layer.alert('您的群已经创建');
                            setTimeout(function () {
                                window.parent.closeLayer();
                            },1000)
                        } else {
                            layer.alert('群创建失败，请联系平台管理员');
                        }
                       
                    });
                });
            })
        });
    </script>
</head>
<body>
    <div style="margin-top:10px;margin-left:5px;width:95%;height:20px;left:25px;padding:20px;">
      
        <div class="layui-form"><i>群名称:</i> <input id="txtGroupName" type="text" maxlength="20" style="height:30px;width:50%" placeholder="群名称"></div>
        
    </div>
    <div style="margin-top:10px;margin-left:5px;width:95%;height:20px;left:25px;padding:20px;">

        <div class="layui-form"><i>群简介:</i> <input id="txtGroupDesc" type="text" maxlength="150" style="height:30px;width:50%" placeholder="群简介"></div>
    </div>
    <div style="margin-top:10px;margin-left:5px;width:95%;height:20px;left:25px;padding:20px; text-align:center;">

        <button  id="btnCreateGroup" class="layui-form-button" style="background-color:#1C86EE;">立马创建</button>
    </div>
</body>
</html>
